import java.util.Scanner;

public class test1 {
    //牛客  DP34  前缀和
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //读入数据
        int n = in.nextInt();int q = in.nextInt();
        int[] arr = new int[n+1];
        for(int i = 1;i<=n;i++){
            arr[i] = in.nextInt();
        }
        //预设一个dp数组
        long[]  dp = new long[n+1];  //防止溢出
        for(int i = 1;i<=n;i++){
            dp[i] = dp[i-1] + arr[i];
        }
        //使用前缀和数组
        while(q>0){
            int l = in.nextInt();int r = in.nextInt();
            q--;
            System.out.println(dp[r]-dp[l-1]);
        }
    }
}
